﻿using System;
using System.Diagnostics;

static class Singleton<TType> where TType : class, new()
{
    public static TType Create()
    {
        Trace.Assert(m_singleton == null, "Attempting to overwrite a singleton object");
        m_singleton = new TType();
        return m_singleton;
    }

    public static void Destroy()
    {
        m_singleton = null;
    }

    public static TType Instance
    {
        get
        {
            Trace.Assert(m_singleton != null, "The Singleton object is NULL");
            return m_singleton;
        }
    }

    private static TType m_singleton = null;
}
